Imports anrControls

Partial Class Content
    Inherits ContentArea

    Dim _pv As New PageView

    Protected Sub Page_PreRender(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.PreRender

        _dbConnection.ContentKey = Me.ContentKey
        Dim smarty As New SmartyPants
        Dim markdown As New Markdown

        'Get the live content and pass it through mark down and smarty.
        Dim liveContent As String = markdown.Transform(_dbConnection.GetContent(0))
        liveContent = smarty.Transform(liveContent, ConversionMode.EducateDefault)

        If _pv.UserName Is Nothing Then

            'Hide the staged content.
            staged_content.Visible = False

            'Output the live content.
            plcLiveContent.Controls.Add(New LiteralControl(liveContent))

        Else

            'Get the staged content and pass it through mark down and smarty.
            Dim stagedContent As String = markdown.Transform(_dbConnection.GetContent(1))
            stagedContent = smarty.Transform(stagedContent, ConversionMode.EducateDefault)

            _litContentStaged.Text = stagedContent

            'Output the live content.
            plcLiveContent.Controls.Add(New LiteralControl("<div class=""live"">" & liveContent & "</div>"))

        End If


    End Sub

End Class
